function getValue(){
	var param=qzsmkocx.GetRetValue();
	return param;
}

function getError(){
	var param=qzsmkocx.GetRetError();
	return param;
}

//修改发卡方信息
function updateInfo_3F00(updateInfo){
	var param=qzsmkocx.UpdateInfo3F00(updateInfo);
	return param
}
//获取3F01   0015文件信息  return Boolean
function get3F01AppInfo(){
	return qzsmkocx.GetBaseInfo_3F01();
	 
}

//修改0015文件(3F10无需修改)
function updateBaseInfo(adf, updateInfo){
	var param
	if(adf=="3F01"||adf=="3F02"){
		param=qzsmkocx.UpdateBaseInfo(adf,updateInfo);
	}
	if(adf=="9A00"){
		param=qzsmkocx.UpdateBaseInfo_9A00(updateInfo);
	}
	return param;
	
}

//修改0016个人文件(3F02无需修改)
function updatePersonInfo(adf,updateInfo){
	var param
	if(adf=="3F01"){
		param=qzsmkocx.UpdatePersonInfo3F01(updateInfo);
	}
	if(adf=="3F10"){
		param=qzsmkocx.UpdatePersonInfo3F10(updateInfo);
	}
	if(adf=="9A00"){
		param=qzsmkocx.UpdatePersonInfo9A00(updateInfo);
	}
	return param;
}

//cpu卡上电
function activeCPU(){
	var param=qzsmkocx.ActiveCPU();
	return param;
}

//******************************获取余额***********************************************

function getBalance(adf,epEd){
	if(!activeCPU()){
		checkError(getError());
		return false;
	}
	var b=qzsmkocx.GetBalance(adf,epEd);//读余额
	return b
	
}
//*****************************圈存业务************************************************
//圈存请求
function ePLoadInit(adfId,epEd,money){
	var flag=qzsmkocx.EPLoadInit(adfId,epEd,money);//调用控件接口
	return flag;
}

//圈存
function epLoad(adfId,epEd,mac2){
	var flag=qzsmkocx.EPLoad(adfId,epEd,mac2);//调用控件接口
	return flag;
}

var again=false;//余额转移防止多次充值
//充值
var Id; //全局应用类型
var epOrEd;//充值钱包类型
var ff=false;//充值是否成功

//充值方法
function pay(adfId,epEd,money){
	epOrEd=epEd
	if(adfId=="3F01"){
		Id="01";
	} else if(adfId=="3F02"){
		Id="02";
	}else if(adfId=="3F10"){
		Id="10";
	}else{
		Id="9A";
	}
	//alert(adfId+","+epEd+","+money);
	if(!activeCPU()){
		
		return false;
	}
	var b=ePLoadInit(adfId,epEd,money);
	var parm="";
	if(b){
		parm=qzsmkocx.GetRetValue();
		//alert(parm);
		$.ajax({
			url:"business/loadRequest",
			dataType:"json",
			async: false,
		    type: 'post',
		    data: {parm:parm,appType:Id},
	        success:loadRequest,
		})
	}else{
		//对卡圈存初始化操作失败
		checkError(getError());
	}
}

//圈存初始化回调函数
function loadRequest(json){
	var param="";
	var adfId="";
	if(Id=="01"){
		adfId="3F01"
	}else if(Id=="02"){
		adfId="3F02"
	}else if(Id=="10"){
		adfId="3F10"
	}else{
		adfId="9A00"
	}
	if(json.statusCode==DWZ.statusCode.ok){
		var citizenCardNo=$("input[name='citizenCardNo']").val();
		//alert(citizenCardNo)
		//验证mac1成功
		var mac2=json.message;
		//发起圈存命令
		var b=epLoad(adfId,epOrEd,mac2);
		if(b){
			//对卡圈存操作成功
			param= qzsmkocx.GetRetValue();
			//alert(param);
			//验证tac
			$.ajax({
				url:"business/load",
				dataType:"json",
				async: false,
			    type: 'post',
			    data: {param:param,citizenCardNo:citizenCardNo,appFlag:adfId,walletType:epOrEd,appType:Id},
		        success:load,
			})
		}else{
			//对卡圈存操作失败
			checkError(getError());
		}
	}else if(json.statusCode=DWZ.statusCode.error){
		//验证mac1失败
		alertMsg.error(json.message);
	}	
}
//圈存回调函数
function load(json){
	var content="";
		if(json.statusCode==DWZ.statusCode.ok){
			//验证圈存tac成功
			$("input[name='newMoney']").val(json.crdBalAft);
			alertMsg.correct(json.message);
			$("#depositBefore").show();
			ff=true;
			//alert(ff)
		}else if(json.statusCode==DWZ.statusCode.error){
			//验证圈存tac失败
			alertMsg.error(json.message);
		}
}

//********************充值撤销*****************************************************************
function rechargeCancel(id,epEd,money){
	//alert(id+","+epEd+","+money)
	if(id=="3F01"){
		appType="01";
	} else if(id=="3F02"){
		appType="02";
	}else if(id=="3F10"){
		appType="10";
	}else{
		appType="9A";
	}
	var b=qzsmkocx.Purchase(id,epEd,money);
	if(b){
		var citizenCardNo=$("input[name='citizenCardNo']").val();
		var result=qzsmkocx.GetRetValue();
		//alert(qzsmkocx.GetRetValue())
		$.ajax({
			url:"business/rechargeCancel",//rechargeCancelTest
			dataType:"json",
			async: false,
		    type: 'post',
		    data: {result:result,citizenCardNo:citizenCardNo,appFlag:id,walletType:epEd,appType:appType},
	        success:function(json){
	        	if(json.statusCode==DWZ.statusCode.error){
					navTabAjaxDone(json)
				}else{
					if(json.flag){
						var f= getBalance(id,epEd);
						if(f==false){
							checkError(qzsmkocx.GetRetError())	
						}
						if(f){
							var value=qzsmkocx.GetRetValue();
							$("input[name='oldMoney']").val(value.split(",")[0]);
							$("input[name='effectiveDate']").val(cardDateToHtml(value.split(",")[1]));
						}
						alertMsg.correct("撤销成功");
					}else{
						alertMsg.error("撤销失败");
					}
				}
				
				
			},
		})			
	}
	else{
		checkError(getError());
	}
}
//*************************************************************************
//****************M1卡读写****************************************************
//*************************************************************************
//初始密钥
var initKey="FFFFFFFFFFFF";
//格式化扇区数据
var initInfo="000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
//格式化扇区密钥(潍坊银行用)
//var initBlock3="FFFFFFFFFFFF7F078800FFFFFFFFFFFF";
var initBlock3="FFFFFFFFFFFFFF078069FFFFFFFFFFFF";
//格式化扇区密钥(其他卡用)
var initBlock3_2="FFFFFFFFFFFFFF078069FFFFFFFFFFFF"
//认证模式
var modeA=0;
var modeB=4;
//M1卡寻卡
function findLogicCard(){
	var f=qzsmkocx.FindLogicCard()
	return f;
}
//M1读取某个扇区某个块值(key[密钥]String,sector[扇区号] Integer,block[块区值] Integer,mode[认证模式] Integer)
//return String
function  readBlockExternal(key,sector,block,mode) {
	var f=qzsmkocx.ReadBlockExternal(key,sector,block,mode);
	if(f){
		return getValue();
	}else{
		return getError();
	}
}
//读取指定扇区所有块值（Key块不读）
//return String 无分隔符

function readSectorExternal(key, sector, mode){
	var f=qzsmkocx.ReadSectorExternal(key,sector,mode);
	if(f){
		return getValue();
	}else{
		return getError();
	}
}
//M1写入某个扇区某个块值(key[密钥]String,sector[扇区号] Integer,block[块区值] Integer,mode[认证模式] Integer,writeInfo[写入数据] String)
function WriteBlockExternal(key,sector,block,mode,writeInfo){
	var f=qzsmkocx.WriteBlockExternal(key,sector,block,mode,writeInfo);
	return f;
}
//M1写入某个扇区所有块值
function writeSectorExternal(key,sector,mode,writeInfo){
	var f=qzsmkocx.WriteSectorExternal(key,sector,mode,writeInfo);
	return f;
}